<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>纠错</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/static/js/layui/css/layui.css"  media="all">
    <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>
<body>
<form class="layui-form" action="">
    <div class="errors" style="padding: 20px">
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">详情描述</label>
            <div class="layui-input-block">
                <textarea name="content" placeholder="请输入错误详情" class="layui-textarea"></textarea>
            </div>
        </div>
        <input type="hidden" name="question" value="{{$data['question']}}">
        <input type="hidden" name="section" value="{{$data['section']}}">
        {{csrf_field()}}

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="submit" class="layui-btn" lay-submit="" lay-filter="errors">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </div>

</form>
<script src="/static/js/layui/layui.all.js"></script>
<script>
    layui.use(['form'], function(){
        var form = layui.form,
            $=layui.jquery;
        form.on('submit(errors)', function(data){
            data=data.field;
            var loading = layer.load(0, {shade: false});
            $.ajax({
                type: 'post',
                url: '{{route('user.question.errors')}}',
                data: data,
                dataType: 'json',
                success: function (data) {
                    layer.close(loading);
                    if (data == 1) {
                        layer.alert('提交成功', {
                            icon: 1,
                            skin: 'layui-layer-molv' //样式类名
                            , closeBtn: 0
                        }, function(){
                            var index = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(index);
                            parent.location.reload();
                        });
                    } else {
                        layer.alert('提交失败', {
                            icon: 2,
                            skin: 'layui-layer-molv' //样式类名
                            , closeBtn: 0
                        });
                    }
                }, error: function (res) {
                    layer.alert('详情最少5个字', {
                        icon: 2,
                        title: '提示信息',
                        skin: 'layui-layer-molv' //样式类名
                        , closeBtn: 0
                    });
                }
            });
            return false;
        });
    });
</script>

</body>
</html>
